﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IoCHelper.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   Helper for finding common class instances for StreetCare MVC
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.Core.IoC
{
    #region Using Directives

    using Infrastructure.Configuration;
    using Infrastructure.IoC;
    using Infrastructure.Logging;
    using Microsoft.WindowsAzure.ServiceRuntime;

    #endregion

    /// <summary>
    /// Helper for finding common class instances for StreetCare MVC
    /// </summary>
    public class IoCHelper
    {
        /// <summary>
        /// Gets the current IoC container
        /// </summary>
        public static IIoCService Current
        {
            get
            {
                return RoleEnvironment.IsAvailable ? new IoCContainer() : (IIoCService)new IoCLocalContainer();
            }
        }

            /// <summary>
        /// Gets the logger.
        /// </summary>
        /// <value>The logger.</value>
        public static ILogger Logger
        {
            get { return Current.Resolve<ILogger>(); }
        }

        /// <summary>
        /// Gets the configuration bag.
        /// </summary>
        /// <value>The configuration bag.</value>
        public static IConfigurationBag ConfigurationBag
        {
            get { return Current.Resolve<IConfigurationBag>(); }
        }
    }
}